<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Docker Zookeeper 集群部署指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
        }
        .code-block {
            background: #1e293b;
            border-radius: 12px;
            position: relative;
            overflow: hidden;
        }
        .code-block::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 40px;
            background: #334155;
            border-bottom: 1px solid #475569;
        }
        .code-content {
            padding: 60px 24px 24px;
            overflow-x: auto;
        }
        .code-content code {
            color: #e2e8f0;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 14px;
            line-height: 1.6;
        }
        .step-number {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-weight: 700;
            font-size: 3rem;
        }
        .section-divider {
            background: linear-gradient(to right, transparent, #e5e7eb, transparent);
            height: 1px;
            margin: 4rem 0;
        }
        .highlight-box {
            background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
            border-left: 4px solid #667eea;
            padding: 1.5rem;
            border-radius: 8px;
            margin: 1.5rem 0;
        }
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 2rem 0;
        }
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        .animate-fadeInUp {
            animation: fadeInUp 0.8s ease-out;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center animate-fadeInUp">
            <h1 class="text-5xl md:text-6xl font-bold mb-6">
                <i class="fab fa-docker mr-4"></i>Docker Zookeeper 集群部署
            </h1>
            <p class="text-xl md:text-2xl opacity-90 max-w-3xl mx-auto">
                构建高可用、可扩展的分布式协调服务，为您的微服务架构提供坚实基础
            </p>
            <div class="mt-10 flex justify-center space-x-8">
                <div class="text-center">
                    <i class="fas fa-server text-4xl mb-2"></i>
                    <p class="text-lg">多节点集群</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-shield-alt text-4xl mb-2"></i>
                    <p class="text-lg">高可用保障</p>
                </div>
                <div class="text-center">
                    <i class="fas fa-rocket text-4xl mb-2"></i>
                    <p class="text-lg">快速部署</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Architecture Visualization -->
    <section class="py-16 px-6 bg-white">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-3xl font-bold text-center mb-12 text-gray-800">
                <i class="fas fa-project-diagram mr-3 text-purple-600"></i>集群架构概览
            </h2>
            <div class="mermaid">
                graph TB
                    subgraph "Docker Network"
                        ZK1[Zookeeper 1<br/>ID: 1]
                        ZK2[Zookeeper 2<br/>ID: 2]
                        ZK3[Zookeeper 3<br/>ID: 3]
                    end
                    
                    Client[客户端应用]
                    
                    Client -->|2181| ZK1
                    Client -->|2181| ZK2
                    Client -->|2181| ZK3
                    
                    ZK1 <-->|2888:3888| ZK2
                    ZK2 <-->|2888:3888| ZK3
                    ZK1 <-->|2888:3888| ZK3
                    
                    style ZK1 fill:#667eea,stroke:#fff,color:#fff
                    style ZK2 fill:#764ba2,stroke:#fff,color:#fff
                    style ZK3 fill:#667eea,stroke:#fff,color:#fff
                    style Client fill:#f3f4f6,stroke:#667eea,stroke-width:2px
            </div>
        </div>
    </section>

    <!-- Deployment Steps -->
    <section class="py-16 px-6">
        <div class="max-w-6xl mx-auto">
            <h2 class="text-4xl font-bold text-center mb-16 text-gray-800">
                <i class="fas fa-tasks mr-3 text-purple-600"></i>部署步骤
            </h2>
            
            <!-- Step 1 -->
            <div class="mb-16 animate-fadeInUp">
                <div class="flex items-start mb-8">
                    <span class="step-number mr-6">1</span>
                    <div class="flex-1">
                        <h3 class="text-2xl font-bold mb-4 text-gray-800">创建 Docker 网络</h3>
                        <p class="text-gray-600 mb-6 text-lg">为了确保 Zookeeper 实例之间的网络通信正常，需要创建一个自定义 Docker 网络：</p>
                        <div class="code-block">
                            <div class="absolute top-3 left-4 flex space-x-2">
                                <div class="w-3 h-3 bg-red-500 rounded-full"></div>
                                <div class="w-3 h-3 bg-yellow-500 rounded-full"></div>
                                <div class="w-3 h-3 bg-green-500 rounded-full"></div>
                            </div>
                            <div class="code-content">
                                <code>docker network create zookeeper-network</code>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Step 2 -->
            <div class="mb-16 animate-fadeInUp">
                <div class="flex items-start mb-8">
                    <span class="step-number mr-6">2</span>
                    <div class="flex-1">
                        <h3 class="text-2xl font-bold mb-4 text-gray-800">配置 Zookeeper 容器</h3>
                        <p class="text-gray-600 mb-6 text-lg">使用 Docker Compose 配置 Zookeeper 集群。创建一个 <code class="bg-gray-200 px-2 py-1 rounded">docker-compose.yml</code> 文件：</p>
                        <div class="code-block">
                            <div class="absolute top-3 left-4 flex space-x-2">
                                <div class="w-3 h-3 bg-red-500 rounded-full"></div>
                                <div class="w-3 h-3 bg-yellow-500 rounded-full"></div>
                                <div class="w-3 h-3 bg-green-500 rounded-full"></div>
                            </div>
                            <div class="code-content">
                                <code><pre>version: '3'
services:
  zookeeper1:
    image: wurstmeister/zookeeper:3.7.1
    container_name: zookeeper1
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=zookeeper1:2888:3888,server.2=zookeeper2:2888:3888,server.3=zookeeper3:2888:3888
    networks:
      - zookeeper-network

  zookeeper2:
    image: wurstmeister/zookeeper:3.7.1
    container_name: zookeeper2
    environment:
      ZOO_MY_ID: 2
      ZOO_SERVERS: server.1=zookeeper1:2888:3888,server.2=zookeeper2:2888:3888,server.3=zookeeper3:2888:3888
    networks:
      - zookeeper-network

  zookeeper3:
    image: wurstmeister/zookeeper:3.7.1
    container_name: zookeeper3
    environment:
      ZOO_MY_ID: 3
      ZOO_SERVERS: server.1=zookeeper1:2888:3888,server.2=zookeeper2:2888:3888,server.3=zookeeper3:2888:3888
    networks:
      - zookeeper-network

networks:
  zookeeper-network:
    driver: bridge</pre></code>
                            </div>
                        </div>
                        <div class="highlight-box mt-6">
                            <p class="text-gray-700"><i class="fas fa-info-circle mr-2 text-purple-600"></i>这个配置文件定义了一个包含三个 Zookeeper 实例的集群。<code class="bg-gray-200 px-2 py-1 rounded">ZOO_MY_ID</code> 用于指定每个 Zookeeper 实例的 ID，<code class="bg-gray-200 px-2 py-1 rounded">ZOO_SERVERS</code> 用于指定集群中的其他服务器。</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Step 3 -->
            <div class="mb-16 animate-fadeInUp">
                <div class="flex items-start mb-8">
                    <span class="step-number mr-6">3</span>
                    <div class="flex-1">
                        <h3 class="text-2xl font-bold mb-4 text-gray-800">启动 Zookeeper 集群</h3>
                        <p class="text-gray-600 mb-6 text-lg">使用 Docker Compose 启动 Zookeeper 集群：</p>
                        <div class="code-block">
                            <div class="absolute top-3 left-4 flex space-x-2">
                                <div class="w-3 h-3 bg-red-500 rounded-full"></div>
                                <div class="w-3 h-3 bg-yellow-500 rounded-full"></div>
                                <div class="w-3 h-3 bg-green-500 rounded-full"></div>
                            </div>
                            <div class="code-content">
                                <code>docker-compose up -d</code>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Step 4 -->
            <div class="mb-16 animate-fadeInUp">
                <div class="flex items-start mb-8">
                    <span class="step-number mr-6">4</span>
                    <div class="flex-1">
                        <h3 class="text-2xl font-bold mb-4 text-gray-800">验证集群状态</h3>
                        <p class="text-gray-600 mb-6 text-lg">确保所有 Zookeeper 实例都正常运行，并且它们能够相互通信：</p>
                        <div class="code-block mb-4">
                            <div class="absolute top-3 left-4 flex space-x-2">
                                <div class="w-3 h-3 bg-red-500 rounded-full"></div>
                                <div class="w-3 h-3 bg-yellow-500 rounded-full"></div>
                                <div class="w-3 h-3 bg-green-500 rounded-full"></div>
                            </div>
                            <div class="code-content">
                                <code>docker exec -it zookeeper1 zkCli.sh</code>
                            </div>
                        </div>
                        <p class="text-gray-600 mb-4 text-lg">在 Zookeeper 客户端中执行 <code class="bg-gray-200 px-2 py-1 rounded">stat</code> 命令来检查集群状态：</p>
                        <div class="code-block">
                            <div class="absolute top-3 left-4 flex space-x-2">
                                <div class="w-3 h-3 bg-red-500 rounded-full"></div>
                                <div class="w-3 h-3 bg-yellow-500 rounded-full"></div>
                                <div class="w-3 h-3 bg-green-500 rounded-full"></div>
                            </div>
                            <div class="code-content">
                                <code>stat</code>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <div class="section-divider"></div>

    <!-- Best Practices -->
    <section class="py-16 px-6">
        <div class="max-w-